package cn.sollyu.SDManager;

import cn.sollyu.SDManger.R;
import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;

public class DatabaseOpenHelper extends SQLiteOpenHelper
{
//	private static final String DATABASENAME_STRING  = "SDManager.db";
	private static final int DATABASEVERSION_INT = 1;
	
	private Context context;
	// 必须传入一个参数，用来识别是谁的数据库对象
	public DatabaseOpenHelper(Context context) {
		super(context, context.getString(R.string.database_file_name), null, DATABASEVERSION_INT);
		this.context = context;
	}
	
	// 当数据库第一次执行时，创建必要的 表

	@Override
	public void onCreate(SQLiteDatabase db) {
		// 文件路径、名称、说明、生成软件、强制删除后果、打开方式
		String sqlString = String.format(context
				.getString(R.string.database_crate_format),
				context.getString(R.string.database_table),
				context.getString(R.string.database_path),
				context.getString(R.string.database_name),
				context.getString(R.string.database_info),
				context.getString(R.string.database_index),
				context.getString(R.string.database_soft),
				context.getString(R.string.database_del),
				context.getString(R.string.database_uri));
//		Toast.makeText(context, sqlString, 1).show();
		db.execSQL(sqlString);
	}
	
	@Override
	public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
		// TODO Auto-generated method stub
		
	}
	
}
